<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="https://www.texmacs.org/2002/extensions" xmlns:m="http://www.w3.org/1998/Math/MathML">
  <head>
    <title>TeXmacs notes</title>
    <meta content="TeXmacs 1.99.15" name="generator"></meta>
    <link href="../resources/notes-base.css" type="text/css" rel="stylesheet"></link>
    <link href="../resources/blog-icon.png" rel="icon"></link>
    <script src="../resources/highlight.pack.js" language="javascript" defer></script>
    <script src="../resources/notes-base.js" language="javascript" defer></script>
  </head>
  <body>
    <div class="notes-header">
      <p>
        <img class="image" src="../resources/texmacs-blog-transparent.png" width="28.116784"></img><span style="margin-left: 2pt"></span><a href="./main.html">[main]</a><em
        class="notes-header-name">Notes on TeXmacs</em>
      </p>
    </div>
    <h1 id="auto-1">Composing TeXmacs graphics with Scheme<span style="margin-left: 1em"></span></h1>
    <p>
      TeXmacs provides a set of graphic primitives, which can be accessed in
      several ways: interactively with the Texmacs editor, directly through
      the TeXmacs source code (TeXmacs trees) or through <class style="font-variant: small-caps">Scheme</class>
      (as <class style="font-variant: small-caps">Scheme</class> trees). The manual at <class class="tmweb-menu"
      style="font-family: sans-serif">Help</class>&rarr;<class class="tmweb-menu" style="font-family: sans-serif">Manual</class>&rarr;<class
      class="tmweb-menu" style="font-family: sans-serif">Creating technical pictures</class><a id="auto-2"></a> describes
      interactive generation and editing of drawings.
    </p>
    <p>
      In this note, we shall step through the generation of a simple drawing
      starting from Scheme code and translating it into a TeXmacs tree which
      then displays the graphics. We assume that the reader is familiar with
      simple Scheme syntax. Two possible web resources for learning <class
      style="font-variant: small-caps">Scheme</class> are the <class style="font-variant: small-caps">Wikipedia</class> book <a
      href="https://en.wikibooks.org/wiki/Scheme_Programming">Scheme programming</a> and <a href="http://www.shido.info/lisp/idx_scm_e.html">Yet Another Scheme
      Tutorial</a> by Takafumi Shido.
    </p>
    <p>
      We want to draw a triangle inscribed inside a semicircle, mark its
      vertices with letters and decorate the drawing with the text TeXmacs.
    </p>
    <p>
      The most comfortable way of generating a drawing with <class style="font-variant: small-caps">Scheme</class>
      is within a session, so that is the way we'll take in this note. We'll
      see in other notes how to <a href="./scheme-graphics-embedding.html">blend seamlessly graphics in a
      document</a> and generate it through external source files.
    </p>
    <p>
      The first step in working with a session is opening it, with <class
      class="tmweb-menu" style="font-family: sans-serif">Insert</class>&rarr;<class class="tmweb-menu" style="font-family: sans-serif">Session</class>&rarr;<class
      class="tmweb-menu" style="font-family: sans-serif">Scheme</class><a id="auto-3"></a>. As a side step, it is
      convenient to select <class class="tmweb-menu" style="font-family: sans-serif">Program bracket
      matching</class><a id="auto-4"></a> in the preferences box under <class class="tmweb-menu"
      style="font-family: sans-serif">Edit</class>&rarr;<class class="tmweb-menu" style="font-family: sans-serif">Preferences</class>&rarr;<class
      class="tmweb-menu" style="font-family: sans-serif">Other</class><a id="auto-5"></a>; this helps coding in <class
      style="font-variant: small-caps">Scheme</class> by highlighting the parenthesis that matches the
      one next to the cursor.
    </p>
    <p>
      Now we will insert our commands at the prompt. We place small comments
      within text fields inserted by choosing <class class="tmweb-menu" style="font-family: sans-serif">Insert text
      field below</class><a id="auto-6"></a> in the contextual menu, while longer
      explanations fit better in breaks between sessions.
    </p>
    <div class="compact-block" style="margin-top: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define pi (acos -1))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
        <p>
          We will work with a circle so we need &pi;!
        </p>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define (pt x y)
  &lsquo;(point ,(number-&gt;string x) ,(number-&gt;string y)))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="margin-bottom: 0.5em; text-indent: 0em">
      <p>
        
      </p>
    </div>
    <p>
      The Scheme function <tt class="verbatim scheme">pt</tt> we just defined generates a
      TeXmacs graphics point parametrized by its <tt class="verbatim scheme">x</tt> and <tt
      class="verbatim scheme">y</tt> coordinates.
    </p>
    <p>
      <font class="tmweb-markup">point</font> is a TeXmacs graphics primitive that
      represents a point and expects two strings. It is represented in <class
      style="font-variant: small-caps">Scheme</class> with a list of three elements, the first element
      in the list being the symbol <tt class="verbatim scheme">point</tt> (since <tt class="verbatim scheme">point</tt>
      is a <class style="font-variant: small-caps">Scheme</class> symbol, it fits well within the
      quasiquote that also defines the list).
    </p>
    <p>
      Using the <tt class="verbatim scheme">pt</tt> function we shall now define a few points.
    </p>
    <p>
      The <class style="font-variant: small-caps">Scheme</class> interpreter expects one expression per
      prompt (evaluates only the first one it finds in each prompt), so we
      enter the expressions we need in separate prompts; the code in external
      <class style="font-variant: small-caps">Scheme</class> programs is&mdash;of course&mdash;more
      compact.
    </p>
    <div class="compact-block" style="margin-top: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
        <p>
          First of all, coordinates for the end points of the diameter, which
          is 4 units long while the center of the circle is at the origin:
        </p>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define pA (pt -2 0))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define pB (pt 2 0))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
        <p>
          Then the third point of the triangle, on the circumference, defined
          with the help of two variables <tt class="verbatim scheme">xC</tt> and <tt class="verbatim scheme">yC</tt>:
        </p>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define xC (- (* 2 (cos (/ pi 3)))))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define yC (* 2 (sin (/ pi 3))))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define pC (pt xC yC))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
        <p>
          Finally the points at which we will mark the triangle's vertices
          with letters:
        </p>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define tA (pt -2.3 -0.5))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define tB (pt 2.1 -0.5))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(define tC (pt (- xC 0.2) (+ yC 0.2)))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="margin-bottom: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <p>
      Let us take a look at the points we just defined. To display them as a
      TeXmacs graphics, we need to insert them in a canvas with the <font
      class="tmweb-markup">graphics</font> primitive, entered in <class style="font-variant: small-caps">Scheme</class>
      as <tt class="verbatim">graphics</tt>. The <class style="font-variant: small-caps">Scheme</class> expression
      that starts with <tt class="verbatim">graphics</tt> contains, after the symbol <tt
      class="verbatim">graphics</tt>, a list of graphical objects; we will then write
      the canvas with our points as <tt class="verbatim scheme">&lsquo;(graphics ,pA ,pB
      ,pC)</tt> with proper quasi- and unquoting (slightly different in the
      final form of the expression). Since <font class="tmweb-markup">graphics</font> by
      itself yields a rather large canvas, we size it down enclosing it in a
      <font class="tmweb-markup">with</font> primitive which specifies the geometry. The <tt
      class="verbatim scheme">(with <span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>.<span
      style="margin-left: 0.16665em"></span> (graphics <span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>.<span
      style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>))</tt> construct needs to be
      quasiquoted as <tt class="verbatim scheme">with</tt> and <tt class="verbatim">graphics</tt> are
      Scheme symbols, so that the <tt class="verbatim">pA</tt>, <tt class="verbatim">pB</tt> and
      <tt class="verbatim">pC</tt> variables, which represent the points, must be
      unquoted. Finally, everything has to be wrapped in the <tt class="verbatim">stree-&gt;tree</tt>
      function to become a TeXmacs tree. The result is a graphical
      representation of the three points:
    </p>
    <div class="compact-block" style="margin-top: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><pre class="verbatim" xml:space="preserve">
Scheme] </pre></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(stree-&gt;tree
&lsquo;(with &quot;gr-geometry&quot; 
     (tuple &quot;geometry&quot; &quot;400px&quot; &quot;300px&quot; &quot;center&quot;)
     (graphics ,pA ,pB ,pC)))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <p>
        <tt class="verbatim"><div align="justify">
          <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
            <p>
              <img src="scheme-graphics-1.png" style="margin-left: 0em; margin-bottom: 0em; margin-right: 0em; margin-top: 0em; vertical-align: -10.9949898989899em; height: 21.9899797979798em"></img>
            </p>
          </div>
        </div></tt>
      </p>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
        <p>
          We can modify the appearance of the points enclosing each of them in
          the <font class="tmweb-markup">with</font> (<class style="font-variant: small-caps">Scheme</class> symbol
          <tt class="verbatim scheme">with</tt>) primitive
        </p>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><pre class="verbatim" xml:space="preserve">
Scheme] </pre></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(stree-&gt;tree
 &lsquo;(with &quot;gr-geometry&quot; 
      (tuple &quot;geometry&quot; &quot;400px&quot; &quot;300px&quot; &quot;center&quot;)
   (graphics 
      (with &quot;color&quot; &quot;blue&quot; ,pA)
      (with &quot;color&quot; &quot;red&quot; ,pB)
      (with &quot;color&quot; &quot;green&quot; ,pC))))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <p>
        <tt class="verbatim"><div align="justify">
          <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
            <p>
              <img src="scheme-graphics-2.png" style="margin-left: 0em; margin-bottom: 0em; margin-right: 0em; margin-top: 0em; vertical-align: -10.9949898989899em; height: 21.9899797979798em"></img>
            </p>
          </div>
        </div></tt>
      </p>
    </div>
    <div class="compact-block" style="margin-bottom: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <p>
      This example, with constructs boxed inside each other, is typical of
      <class style="font-variant: small-caps">Scheme</class>: we compose a list out of other lists. In
      this case we pass then the list, made of lists, symbols and strings, to
      the function <tt class="verbatim scheme">stree-&gt;tree</tt> that turns it into a TeXmacs
      tree.
    </p>
    <p>
      The next step is composing more complex graphical objects using the
      points we defined.
    </p>
    <p>
      We will use the TeXmacs graphical objects <tt class="verbatim scheme">arc</tt>, <tt
      class="verbatim scheme">line</tt>, <tt class="verbatim scheme">cline</tt> and <tt class="verbatim scheme">text-at</tt>.
      Their meaning and <class style="font-variant: small-caps">Scheme</class> syntax is described in
      the following table:
    </p>
    <table style="width: 100%">
      <tbody><tr>
        <td style="border-top: 1px solid; border-bottom: 1px solid; border-left: 0px solid">object</td>
        <td style="border-top: 1px solid; border-bottom: 1px solid">description</td>
        <td style="border-top: 1px solid; border-bottom: 1px solid; border-right: 0px solid">Scheme syntax</td>
      </tr><tr>
        <td style="border-top: 1px solid"><tt class="verbatim scheme">arc</tt></td>
        <td style="border-top: 1px solid"><p>
          an arc of circle, defined by three points
        </p></td>
        <td style="border-top: 1px solid"><tt class="verbatim scheme">(arc point<sub>1</sub> point<sub>2</sub>
        point<sub>3</sub>)</tt></td>
      </tr><tr>
        <td><tt class="verbatim scheme">line</tt></td>
        <td><p>
          a polyline, defined by two or more points
        </p></td>
        <td><tt class="verbatim scheme">(line point<sub>1</sub> point<sub>2</sub> [<span style="margin-left: 0.16665em"></span>.<span
        style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>
        point<sub>n</sub>])</tt></td>
      </tr><tr>
        <td><tt class="verbatim scheme">cline</tt></td>
        <td><p>
          a closed polyline, defined by three or more points
        </p></td>
        <td><tt class="verbatim scheme">(cline point<sub>1</sub> point<sub>2</sub>
        point<sub>3</sub> [<span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>.<span
        style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span> point<sub>n</sub>])</tt></td>
      </tr><tr>
        <td><tt class="verbatim scheme">text-at</tt></td>
        <td><p>
          a text box, whose position is defined with a single point
        </p></td>
        <td><tt class="verbatim scheme">(text-at string point)</tt></td>
      </tr></tbody>
    </table>
    <p>
      Before composing the full drawing, let us take a look at one of the
      constructs; as an example we choose <tt class="verbatim scheme">cline</tt>. We place it
      as usual inside a <tt class="verbatim scheme">with</tt> construct to select the color and
      we wrap the <tt class="verbatim scheme">with</tt> up in the <tt class="verbatim scheme">graphics</tt>
      primitive, which is in turn enclosed in its own <tt class="verbatim scheme">with</tt>
      which sets the <tt class="verbatim scheme">&quot;gr-geometry&quot;</tt> property of the
      graphics object: 
    </p>
    <div class="compact-block" style="margin-top: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><pre class="verbatim" xml:space="preserve">
Scheme] </pre></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(stree-&gt;tree
 &lsquo;(with &quot;gr-geometry&quot; 
     (tuple &quot;geometry&quot; &quot;400px&quot; &quot;300px&quot; &quot;center&quot;)
     (graphics
        (with &quot;color&quot; &quot;red&quot;   (cline ,pA ,pB ,pC)))))</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <p>
        <tt class="verbatim"><div align="justify">
          <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
            <p>
              <img src="scheme-graphics-3.png" style="margin-left: 0em; margin-bottom: 0em; margin-right: 0em; margin-top: 0em; vertical-align: -10.9949898989899em; height: 21.9899797979798em"></img>
            </p>
          </div>
        </div></tt>
      </p>
    </div>
    <div class="compact-block" style="margin-bottom: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <p>
      We are ready to compose our drawing; as usual the syntax is 
    </p>
    <div class="tmweb-code">
      <pre class="verbatim scheme" xml:space="preserve">
(graphics object_1 object_2 <span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span>.<span style="margin-left: 0.16665em"></span> object_n)</pre>
    </div>
    <p>
      properly enclosed in other constructs (we change the linewidth as well
      as the color and we set the font shape for the whole graphics to
      italics), with the appropriate sequence of quasiquoting and unquotings:
    </p>
    <div class="compact-block" style="margin-top: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><pre class="verbatim" xml:space="preserve">
Scheme] </pre></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
(stree-&gt;tree
 &lsquo;(with &quot;gr-geometry&quot; 
    (tuple &quot;geometry&quot; &quot;400px&quot; &quot;300px&quot; &quot;center&quot;)
    &quot;font-shape&quot; &quot;italic&quot;
    (graphics
      ;; the arc and the line together make the semicircle
      (with &quot;color&quot; &quot;black&quot;  (arc ,pA ,pC ,pB))
      (with &quot;color&quot; &quot;black&quot;  (line ,pA ,pB))
      ;; a closed polyline for the triangle
      (with &quot;color&quot; &quot;red&quot; &quot;line-width&quot; &quot;1pt&quot; (cline ,pA ,pB ,pC))
      ;; add letters using text-at
      (with &quot;color&quot; &quot;black&quot;  (text-at &quot;A&quot; ,tA))  
      (with &quot;color&quot; &quot;black&quot;  (text-at &quot;B&quot; ,tB))  
      (with &quot;color&quot; &quot;black&quot;  (text-at &quot;C&quot; ,tC))
      ;; finally decorate with the TeXmacs symbol
      (with &quot;color&quot; &quot;blue&quot;  &quot;font-shape&quot; &quot;upright&quot; 
        (text-at (TeXmacs) ,(pt -0.55 -0.75)))))) 
;; and close all of the parentheses!!!</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <div class="compact-block" style="text-indent: 0em">
      <p>
        <tt class="verbatim"><div align="justify">
          <div class="ornament" style="background-color:#fff0;border-width:0px;padding-left:0.5em;padding-right:0.5em;border-radius:0px;padding-top:0.5em;padding-bottom:0.5em;display:block;">
            <p>
              <i><img src="scheme-graphics-4.png" style="margin-left: 0em; margin-bottom: 0em; margin-right: 0em; margin-top: 0em; vertical-align: -10.9949898989899em; height: 21.9899797979798em"></img></i>
            </p>
          </div>
        </div></tt>
      </p>
    </div>
    <div class="compact-block" style="margin-bottom: 0.5em; text-indent: 0em">
      <div class="ornament" style="background-color:#ffffdf;border-width:1px;padding-left:0.5em;padding-right:0.5em;border-left-color:#dfdfdf;border-top-color:grey;border-radius:0px;;display:block;">
        <table style="width: 100%">
          <tbody><tr>
            <td style="text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><font color="#008000"><tt class="verbatim">Scheme] </tt></font></td>
            <td style="width: 100%; text-align: left; padding-left: 0em; padding-right: 0em; padding-bottom: 0em; padding-top: 0em"><pre class="verbatim" xml:space="preserve">
</pre></td>
          </tr></tbody>
        </table>
      </div>
    </div>
    <p>
      In follow-up tutorials we will see how to <a href="./scheme-graphics-embedding.html">embed seamlessly
      <class style="font-variant: small-caps">Scheme</class> graphics in a document</a> using the <class
      class="tmweb-menu" style="font-family: sans-serif">Fold</class>&rarr;<class class="tmweb-menu" style="font-family: sans-serif">Executable</class><a
      id="auto-7"></a> environment and how to generate them from external files.
    </p>
    <p>
      As a conclusion of this note, here is a collection of TeXmacs graphical
      objects, illustrating a few possibilities:
    </p>
    <p>
      <img src="scheme-graphics-5.png" style="margin-left: -0.0206868686868687em; margin-bottom: 0em; margin-right: -0.020686868686866em; margin-top: 0em; vertical-align: -10.9949898989899em; height: 21.9899797979798em"></img>
    </p>
  </body>
</html>